package com.pengshun.modules.api.mapper;

import com.pengshun.modules.common.PagePara;
import com.pengshun.modules.domain.UserWithdraw;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface PsUserInComRecordMapper {

    /**
     * 更新账户可用余额
     * @param oldBlanace
     * @param newBlanace
     * @param userId
     * @return
     */
    @Update("update ps_income  set usable_blanace =#{newBlanace},account_blanace=#{userNowAccountBlanace} where usable_blanace=#{oldBlanace} and  user_id=#{userId} and account_blanace=#{accountBlanace}")
    int updateBlanace(@Param("oldBlanace") BigDecimal oldBlanace, @Param("newBlanace") BigDecimal newBlanace, @Param("userId") Long userId,
                      @Param("accountBlanace") BigDecimal accountBlanace, @Param("userNowAccountBlanace") BigDecimal userNowAccountBlanace);

    /**
     * 更新油气卡余额
     * @param oldBlanace
     * @param newBlanace
     * @param userId
     * @return
     */
    @Update("update ps_income  set oil_card_blanace =#{newBlanace}  where oil_card_blanace=#{oldBlanace} and  user_id=#{userId} ")
    int updateOilBlanace(@Param("oldBlanace") BigDecimal oldBlanace, @Param("newBlanace") BigDecimal newBlanace, @Param("userId") Long userId);

    List<UserWithdraw> selectWithdrawRecordList(@Param("page") PagePara page, @Param("useId") Long useId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

}
